# -*- mode: python ; coding: utf-8 -*-

import sys
from PyInstaller.utils.hooks import collect_data_files, collect_submodules

# 收集FastAPI相关数据文件
fastapi_datas = collect_data_files('fastapi')
uvicorn_datas = collect_data_files('uvicorn')
pydantic_datas = collect_data_files('pydantic')

# 收集所有隐藏导入
hidden_imports = []
hidden_imports.extend(collect_submodules('fastapi'))
hidden_imports.extend(collect_submodules('uvicorn'))
hidden_imports.extend(collect_submodules('pydantic'))
hidden_imports.extend(collect_submodules('serial'))
hidden_imports.extend(['uvicorn.logging', 'uvicorn.loops', 'uvicorn.loops.auto', 
                      'uvicorn.protocols', 'uvicorn.protocols.http', 'uvicorn.protocols.websockets',
                      'uvicorn.lifespan', 'uvicorn.lifespan.on'])

a = Analysis(
    ['app.py'],
    pathex=[],
    binaries=[],
    datas=fastapi_datas + uvicorn_datas + pydantic_datas + [('static', 'static')],
    hiddenimports=hidden_imports,
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=None,
    noarchive=False,
)

pyz = PYZ(a.pure, a.zipped_data, cipher=None)

exe = EXE(
    pyz,
    a.scripts,
    [],
    exclude_binaries=True,
    name='net-tools',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)

coll = COLLECT(
    exe,
    a.binaries,
    a.zipfiles,
    a.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name='net-tools',
)